home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr49
/
actlib13.zip
/
TOOLS.ZIP
/
TMPPATH.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-25
|
1KB
|
58 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#include "tools.h"
#include <stdlib.h>
#include <string.h>
#include <dos.h>
/***
*
* Function : gettmppath
*
* Topics : Transforms a filename into a full pathname
* relative to temporary directory.
*
* Parameters : in/out char *filename filename
*
* Return : pointer to filename
*
***/
char *gettmppath( char *filename )
{ char *ptr;
ptr = getenv( "TEMP" );
if ( ! ptr || ! *ptr ) ptr = getenv( "temp" );
if ( ! ptr || ! *ptr ) ptr = getenv( "TMP" );
if ( ! ptr || ! *ptr ) ptr = getenv( "tmp" );
if ( ptr && *ptr ) { char buffer[_MAX_PATH];
strcpy( buffer, filename );
_makepath( filename, "", ptr, buffer, "");
strupr( filename );
}
else getpgmpath( filename );
return filename;
}
#ifdef MAIN
#include <stdio.h>
#include <conio.h>
void main( void )
{ char f[_MAX_PATH] = "abc.ext";
putenv( "TEMP=e:\\tmp" );
putenv( "TMP=c:\\tmp" );
clrscr();
printf( "%s\n", gettmppath(f) );
getch();
}
#endif